<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <span v-if="loginType==1">
      <label for="username">用户名</label>
      <input type="text" id="username" placeholder="请输入用户名" key="username">
    </span>
    <span v-else="loginType==2">
      <label for="phone">手机号</label>
      <input type="text" id="phone" placeholder="请输入手机号" key="phone">
    </span>
    <button @click="typeChange">登录方式切换</button>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      methods: {
        typeChange() {
          if (this.loginType === 1) {
            this.loginType = 2
          } else {
            this.loginType = 1
          }
        }
      },
      data: {
        loginType: 1,
      },
    })
  </script>
</body>
</html>